package com.mir.dubbo.autoconfigure;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

/**
 * Created by miracle on 2017/2/19.
 *
 * @author Miracle.XJH
 * @title DubboAutoConfiguration
 * @date 2017年02月19日 15:36:06
 */
@Configuration
@EnableConfigurationProperties(DubboProperties.class)
@ConditionalOnProperty(name = "dubbo.enabled", matchIfMissing = true)
@ImportResource(value = {
        "classpath:/dubbo/dubbo.xml",
        "classpath:/dubbo/dubbo-consumer.xml",
        "classpath:/dubbo/dubbo-provider.xml"
})
@Slf4j
public class DubboAutoConfiguration {
    @Autowired
    private DubboProperties dubboProperties;

    public DubboAutoConfiguration() {
        log.info("enable dubbo config!");
        log.info("dubbo properties：{}", JSON.toJSONString(dubboProperties));
    }
}
